
<template>
    <div class="port-page">
        <!-- 顶部按钮 -->
         <div class="but1">
          <router-link to="/home">
           	<el-button type="warning" size="small"   style=' margin-right: 10px;'  icon="el-icon-menu">首页</el-button>
          </router-link>
          <el-button type="primary" size="small"   style=' margin-right: 10px;' @click="baocun"  >保存</el-button>
        </div>
        <div class="jd">
          <h1>阶段设置</h1>
          <ul>
            <li>第一阶段：<el-input v-model="mc1" placeholder="请输入第一阶段名称" class="lll" ></el-input></li>
            <li>第二阶段：<el-input v-model="mc2" placeholder="请输入第二阶段名称" class="lll" ></el-input></li>
            <li>第三阶段：<el-input v-model="mc3" placeholder="请输入第三阶段名称" class="lll" ></el-input></li>
            <li>第四阶段：<el-input v-model="mc4" placeholder="请输入第四阶段名称" class="lll" ></el-input></li>
            <li>第五阶段：<el-input v-model="mc5" placeholder="请输入第五阶段名称" class="lll" ></el-input></li>
          </ul>
        </div>
        <div class="gz">
          <h1>客户回收规则</h1>
          <ul>
            <li> <input v-model="gz1" >天没有互动计划自动回收到公共资源库</li>
            <li>每人限制同时跟进 <input v-model="gz2">个资源</li>
            <li>无效客户标记规则：
              <el-radio-group v-model="gz3">
                <el-radio :label="'1'">标记为临时无效</el-radio>
                <el-radio :label="'2'">标记为彻底无效</el-radio>
              </el-radio-group>
            </li>
          </ul>
        </div>
        <LoadingComponent v-show="isLoading"></LoadingComponent>
    </div>

</template>
<script>
    import { mapState } from 'vuex'
    import qs from 'qs'
    import LoadingComponent from 'components/loading'
      export default {
        components: { LoadingComponent},
        data () {
            return {

            	/*qxbtn:{
					//课程价格
					frmrskcjgaddyn:false,
					frmrskcjgedityn:false,
					frmrskcjgdelyn:false,
				},
*/
              mc1:'',
              mc2:'',
              mc3:'',
              mc4:'',
              mc5:'',
              gz1:'',
              gz2:'',
              gz3:'1',
               vkeyword:'', // keyword

				multipleDelNum:'', //获取批量选择的数据
                dataList: [],  //表格数据
                comboxlist:[], //下拉框 动态的
                vcomautovalue:'',//下拉框name 动态的
                vcomgdvalue:'',//下拉框name 固定的

				/*动画加载*/
                isLoading: true,//动画加载
                searchLoading: false,//搜索按钮触发按钮动画
            }
        },
        created () {
          this.isLoading = true;//动画开始
            this.$store.dispatch('changeTitle','阶段规则设置');//修改title
            this.$store.dispatch('changeRouterIndex','/admin/jdgzsz');//修改路由
            this.search();//分页获取默认数据
            this.search2();//分页获取默认数据
            // this.getcomlist(); //加载下拉列表
        },
        mounted () {
            //加载完成之后event
            this.isLoading = false;//动画结束
        },
        methods: {
          search () {
		    //查询搜索触发事件
    		    var logininfo = JSON.parse(localStorage.logininfo);
                 this.searchLoading = true;
                 var params2 = qs.stringify({
                    xxid:logininfo.xxid,
                 })
                 this.axios.post(this.$store.state.api + 'jd/jdlist',  params2 )
                 .then(res => {
                    let data = res.data.data;
                    this.mc1 = data.mc1.mc1
                    this.mc2 = data.mc2.mc1
                    this.mc3 = data.mc3.mc1
                    this.mc4 = data.mc4.mc1
                    this.mc5 = data.mc5.mc1
                    this.searchLoading = false;
                 }).catch(res => {
    					 console.log(res)
                      this.searchLoading = false;
    				})
          },
          search2 () {
		    //查询搜索触发事件
    		    var logininfo = JSON.parse(localStorage.logininfo);
                 this.searchLoading = true;
                 var params2 = qs.stringify({
                    xxid:logininfo.xxid,
                    yhid:logininfo.id
                 })
                 this.axios.post(this.$store.state.api + 'xx/info',  params2 )
                 .then(res => {
                    console.log(res,111)
                    this.gz1 = res.data.data.gz1
                    this.gz2 = res.data.data.gz2
                    this.gz3 = res.data.data.gz3
                    this.searchLoading = false;
                 }).catch(res => {
    					 console.log(res)
                      this.searchLoading = false;
    				})
          },
          baocun(){
            var logininfo = JSON.parse(localStorage.logininfo);
                 this.searchLoading = true;
                 var params2 = qs.stringify({
                    mc1:this.mc1,
                    mc2:this.mc2,
                    mc3:this.mc3,
                    mc4:this.mc4,
                    mc5:this.mc5,
                    gz1:this.gz1,
                    gz2:this.gz2,
                    gz3:this.gz3,
                    xxid:logininfo.xxid,
                    yhid:logininfo.id
                 })
                 this.axios.post(this.$store.state.api + 'jd/updatejd',  params2 )
                 .then(res => {
                    console.log(res,111)
                    if(res.data.code == 1){
                      this.$message({  message: '保存成功!', type: 'success'});
                    }else{
                      this.$message({  message: '服务器错误，保存失败请重试！', type: 'error'});
                    }
                 }).catch(res => {
                      console.log(res)
                      this.$message({  message: '服务器错误，保存失败，请重试！', type: 'error'});
                      this.searchLoading = false;
           })
          },
          getcomlist(){
          /*  var logininfo = JSON.parse(localStorage.logininfo) ;
            this.axios.get(this.$store.state.api + 'dome/list',{
                params:{
                    yhid:logininfo.id,
                    xxid:logininfo.xxid
                }
            }).then( res => {
                console.log(res)
                let data = res.data.data;
                let list = data.list;
                this.total = data.totalPage;
                this.dataList = list;
                this.searchLoading = false;
            }).catch( res => {
            })  */
          } ,
          tableCellControl (scope) {
            //表格单元格控制CSS样式
                /*if (scope.row.id == 112 && scope.column.property == "iname") {
                    return {
                        color:"red",
                    }
                }else{
                    return {
                        color:"green",
                    }
                }*/
           },
           handleSizeChange (val) {//每页显示条数触发事件
                this.pagesize = val;
                this.pageindex = 1;
                this.search();
            },
            handleCurrentChange (val) {//分页触发事件
                this.search();
            },
            checkSelect (selection, row) {//点击单选select触发事件
                console.log(selection, row)
                let strID = [];
                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                this.multipleDelNum = strID.join(",");
            },
            checkall (selection) {//点击全选select触发事件
                let strID = [];
                selection.forEach(function(v,i){
                    strID.push(v.id)
                })
                this.multipleDelNum = strID.join(",");
            },
            /* 组件的弹框  */
            componentsShow (type,data) { //显示组件
                console.log(type,data)
                for ( let i in this.portComponents ) {
                    if (type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = true;
                        this.portComponents[i].params = data;
                        if (this.portComponents[i].data.type == 'single') {
                            this.portComponents[i].data.index = data.row.id
                        }else if(this.portComponents[i].data.type == 'multiple'){
                            this.portComponents[i].data.index = this.multipleDelNum;
                        }else{
                            return;
                        }
                        return;
                    }
                }
            },
            componentsHide (setting) { //关闭组件
                console.log(setting)
                for ( let i in this.portComponents ) {
                    if (setting.type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = false;
                        if (!setting.cancel) {
                           this.search();
                        }
                        return;
                    }
                }
            }
        },
        computed: {
            ...mapState([
                'api'//域名
            ]),
            multipleDeleteDisabled () {
                console.log(this.multipleDelNum)
                if (this.multipleDelNum) {
                    return false;
                }else{
                    return true
                }
            }
        }
    }
</script>

<style lang="less" scoped>

    .but1{
    	width: 30%;
    	margin-top: 8px;
      margin-left: 20px;
		}
    .jd{
      margin-left: 20px;
      h1{
        font-size: 23px;
      }
      ul{
        margin-left: 30px;
        li{
          margin-top: 20px;
          .lll{
            width: 200px;
          }
        }

      }
    }
    .gz{
      margin-left: 20px;
      h1{
        font-size: 23px;
      }
      ul{
        margin-left: 30px;
        li{
          margin-top: 20px;
          input{
            width: 50px;
            border: 0;
            border-bottom: 1px solid;
            background: #E8EDF0;
            text-align: center;
          }
        }

      }
    }



</style>
